<?php

/*
 * Action 4$
 *
 * +2$
 * You may put your deck into your discard pile. Look through your discard pile and put one card from it on top of your deck.
 */

class Scavenger extends Card implements iAction, iKingdom, iDarkAges {

    public function __construct() {
        parent::__construct("Scavenger", 4);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+2$",
            "You may put your deck into your discard pile. Look through your discard pile and put one card from it on top of your deck.");
    }

    public function play(Game $game, $isRealCard) {

        $game->addMoney(new Price(2));
        ScreenDisplay::addScreenMessage($game, true, " get +2$ ", "gets +2$");
        $options = array(new Option(1, "Yes"), new Option(2, "No"));
        $output = MySocket::GetUserReply($game, Input_ChooseOne, $options, 1, 1, null, "Put draw pile in discard?");

        $answer = $output[0];
        if ($answer == "Yes") {
            $game->putDrawPileInDiscard();
            ScreenDisplay::addScreenMessage($game, false, " and discard  the draw deck ", " and discards the draw deck");
        } else {
            ScreenDisplay::addScreenMessage($game, false, " and do not discard the draw deck ", " and does not discard the draw deck");
        }

        $discardDeck = $game->getDiscardDeck();

        if (sizeof($discardDeck) > 0) {
            $discardDeck = getUniqueCards($discardDeck);
            $discardDeck[] = new Option(1, "None");
            $output = MySocket::GetUserReply($game, Input_ChooseOne, $discardDeck, 1, 1, null, "Choose a card to put on top of your deck");
            $answer = $output[0];
            if ($answer != "None") {
                $game->moveCardFromPileToPile($answer, DiscardPile, DrawPile);
                ScreenDisplay::addScreenMessage($game, true, "put back " . nicePrint($answer) . " on top of your deck", "puts back " . sizeof($output) . " cards back on top of his deck");
            } else {
                ScreenDisplay::addScreenMessage($game, true, "put back nothing", "puts back nothing");
            }
        } else {
            ScreenDisplay::addScreenMessage($game, true, "put back nothing", "puts back nothing");
        }
        $game->cardActionFinished();
        return true;
    }

}

?>